package band.wukong.practice.webservice.kh.sample05.nongen;

import band.wukong.practice.webservice.kh.sample05.JukeboxService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;

import javax.xml.namespace.QName;
import javax.xml.soap.SOAPException;
import javax.xml.ws.Service;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * 通过JAX-WS实现
 * @author wukong(wukonggg@139.com)
 */
public class JukeboxClientByJAXWS {

    private final Logger logger = LoggerFactory.getLogger(JukeboxClientByJAXWS.class);

    @Test
    public void test() throws MalformedURLException, SOAPException {
        URL url = new URL(JukeboxConst.SERVICE_WSDL);
        QName qname = new QName(JukeboxConst.SERVICE_NS, JukeboxConst.SERVICE_NAME);
        Service service = Service.create(url, qname);
        JukeboxService box = service.getPort(JukeboxService.class);
        logger.info(box.randomArtist(MusicConst.GENRE_CLASSIC));
        logger.info(box.randomArtist(MusicConst.GENRE_JAZZ));
        logger.info(box.randomArtist(MusicConst.GENRE_METAL));
    }
}
